package com.jandan.ui.client;

import com.gwtext.client.core.EventObject;

import com.gwtext.client.data.Node;
import com.gwtext.client.widgets.tree.TreeNode;
import com.gwtext.client.widgets.tree.TreePanel;
import com.gwtext.client.widgets.tree.event.TreeNodeListenerAdapter;

public class ExtendedInfoPanel extends TreePanel {
	private ILessonOperator lessonOperator;
	
	public ExtendedInfoPanel(ILessonOperator lessonOperator){
		this.lessonOperator = lessonOperator;
		this.setTitle("更多信息");
		this.setRootNode(new TreeNode("extended information"));
		this.setRootVisible(false);

//		this.addListener(new TreePanelListenerAdapter() {
//			public void onContextMenu(TreeNode node, EventObject e) {
//				int[] xy = e.getXY();
//				// MessageBox.alert(node.getId());
//				showContextMenu(node, e);
//			}
//		});
		this.createComponent();
		
	}
	
	private void createComponent(){
		//所有词库
		TreeNode root = this.getRootNode();

		TreeNode allWordLibNode = new TreeNode("所有词库");
		allWordLibNode.setExpanded(false);
		allWordLibNode.setId("all_word_libs");
		
		allWordLibNode.addListener(new TreeNodeListenerAdapter(){

			@Override
			public void onClick(Node node, EventObject e) {
				// TODO Auto-generated method stub
				lessonOperator.displayAllWordLib();
			}
			
		});
		
		root.appendChild(allWordLibNode);
		
		

		
		//使用技巧
		TreeNode mannalNode = new TreeNode("使用技巧");
		mannalNode.setExpanded(false);
		mannalNode.setId("mannal");
		root.appendChild(mannalNode);
	}
}
